/***************************************************************************
 *   Copyleft 2008-2009 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#include "./vState.h"

namespace Vendetta {
	vState::vState() {
	}

	vState::~vState() {
	}


	//	Reset shading state.
	vVoid vState::Reset() {
		// Set permanent state
		SetClearColor(vColor::Black);
		SetClearDepth(1.0);
		SetBlend(OFF);
		SetBlendFunc(ONE, ONE);

		SetAlphaTest(OFF);
		SetAlphaFunc(ALWAYS, 0);

		SetColor(1, 1, 1, 1);
		SetColorMask(ON, ON, ON, ON);

		SetDepthTest(ON);
		SetDepthFunc(LEQUAL);
		SetDepthMask(ON);

		SetStencilTest(OFF);
		SetStencilFunc(ALWAYS, 0, ~0);
		SetStencilOps(KEEP, KEEP, KEEP);

		SetCulling(ON);
		SetCullingFunc(BACK);
		SetCullingMode(CCW);

		SetFill(SOLID);
		SetShading(GOURAUD);
		
		// Permanent state tells: first texture unit Enabled
		for (vInt i = 0; i < mNumTextureUnits; i++) {
			DisableTexture(i);
			ResetTexture(i);
		}
		EnableTexture(0);
	}


	/*
	 *	All terms required to describe current shading state.
	 */

	vInt vState::OFF;
	vInt vState::ON;

	// Blend function
	vInt vState::ZERO;
	vInt vState::ONE;
	vInt vState::SRC_COLOR;
	vInt vState::ONE_MINUS_SRC_COLOR;
	vInt vState::DST_COLOR;
	vInt vState::ONE_MINUS_DST_COLOR;
	vInt vState::SRC_ALPHA;
	vInt vState::ONE_MINUS_SRC_ALPHA;
	vInt vState::DST_ALPHA;
	vInt vState::ONE_MINUS_DST_ALPHA;

	// Alpha test
	//vInt vState::OFF;
	//vInt vState::ON;

	// Alpha function
	vInt vState::EQUAL;
	vInt vState::LEQUAL;
	vInt vState::LESS;
	vInt vState::NOTEQUAL;
	vInt vState::GREATER;
	vInt vState::GEQUAL;
	vInt vState::ALWAYS;
	vInt vState::NEVER;

	// Depth
	//vInt vState::OFF;
	//vInt vState::ON;

	// Depth function
	//vInt vState::EQUAL;
	//vInt vState::LEQUAL;
	//vInt vState::LESS;
	//vInt vState::NOTEQUAL;
	//vInt vState::GREATER;
	//vInt vState::GEQUAL;
	//vInt vState::ALWAYS;
	//vInt vState::NEVER;

	// Depth mask
	//vInt vState::OFF;
	//vInt vState::ON;

	// Stencil
	//vInt vState::OFF;
	//vInt vState::ON;

	// Stencil function
	//vInt vState::EQUAL;
	//vInt vState::LEQUAL;
	//vInt vState::LESS;
	//vInt vState::NOTEQUAL;
	//vInt vState::GREATER;
	//vInt vState::GEQUAL;
	//vInt vState::ALWAYS;
	//vInt vState::NEVER;

	// Stencil operation
	vInt vState::KEEP;
	//vInt vState::ZERO;
	vInt vState::REPLACE;
	vInt vState::INCR;
	vInt vState::DECR;
	vInt vState::INVERT;

	// mColor mask
	//vInt vState::ON;
	//vInt vState::OFF;

	// mCulling
	//vInt vState::OFF
	//vInt vState::ON;
	vInt vState::CCW;
	vInt vState::CW;

	// mCulling function
	vInt vState::FRONT;
	vInt vState::BACK;

	// mShading
	vInt vState::FLAT;
	vInt vState::GOURAUD;

	// mFill
	vInt vState::SOLID;
	vInt vState::WIRE;
	vInt vState::POINTS;

	// mLighting
	//vInt vState::OFF;
	//vInt vState::ON;

	// mSpecular
	//vInt vState::OFF;
	//vInt vState::ON;
}